package com.kaibes.module.permission.db.listener;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.kaibes.module.permission.db.service.PowerService;
import com.kaibes.module.permission.db.service.RoleService;
import com.kaibes.module.user.UserService;
import com.kaibes.orm.spring.OrmListener;
import com.kaibes.orm.spring.jdbc.DeleteListenerWithId;

@OrmListener(service = RoleService.class)
public class RoleDeleteListener extends DeleteListenerWithId<RoleService> {

    @Autowired
    private PowerService powerService;
    @Autowired
    private UserService userService;
    
    @Override
    protected void afterDelete(List<Object> idList) throws Exception {
        userService.updateRoleIdByRoleId(idList, 1);
        powerService.clearCache();
    }
    
}
